home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / bb / src / titlemod.c < prev   
Encoding:
C/C++ Source or Header  |  1993-11-30  |  4.3 KB  |  213 lines

  1. /*
  2.         title mode operation
  3.                       1993.6.27 v1.0
  4.                       copyright Y.Ouchi
  5. */
  6.  
  7. #include    <stdio.h>
  8. #include    <string.h>
  9. #include    "egb.h"
  10. #include    "mos.h"
  11. #include    "bb.h"
  12.  
  13.     /* 関数プロトタイプ宣言 */
  14. extern    char    egbwork[];
  15. extern    char    moswork[];
  16. extern    void    linedsp(int, int, char *);
  17. extern    void    linedspv(int, int, char *, int, unsigned int, unsigned int);
  18. extern    void    box(int, int, int, int, int, int);
  19. extern    int        panelread(int, struct panel *, int);
  20.         void    lineset(char *, char *, int);
  21.  
  22. extern    int        max_text;
  23. extern    int        dispmode;
  24.  
  25. int titlemod ( char *log, int leng, char **title,
  26.                     struct logcontent *intext, short *disptext, int *textno)
  27. {
  28.     int        i,k,flag,n;
  29.     char    logtitle[TITLE_LINE_NO][90];
  30.     char    logkind[TITLE_LINE_NO];
  31.     int        tcol;
  32.     int        pos=0;
  33.     int        result,action;
  34.     int        logindex;
  35.     char    *change_page={"▲  page up/down  ▼   ( use mouse bottan or pad trigger )"};
  36.     struct    panel    n_menu[1];
  37.  
  38.  
  39.                     /* page move char display */
  40.     EGB_writePage(egbwork,1);
  41.     linedsp( 6,52,change_page );
  42.     EGB_writePage(egbwork,0);
  43.  
  44.                     /* title display select */
  45.     MOS_horizon( 0,639 );
  46.     MOS_vertical( 35,448 );
  47.     MOS_setpos( 120, 60 );
  48.     MOS_disp( 1 );
  49.  
  50.     flag=1;
  51.     while ( flag ){
  52.  
  53.                     /* title dsiplay arrary make */
  54.         for (i=0;i<TITLE_LINE_NO;i++){
  55.             if ( *textno+i < max_text ){
  56.                 logindex=disptext[*textno+i];
  57.                 if (intext->text[logindex].text.id!=TITLE_ID){
  58.                     if (intext->text[logindex].text.leng>0){
  59.                         lineset(&log[intext->text[logindex].text.pos],
  60.                                 logtitle[i],
  61.                                 intext->text[logindex].text.work);
  62.                         logkind[i]=0;
  63.                     }
  64.                     else{
  65.                         logtitle[i][0]=0x00;
  66.                     }
  67.                 }
  68.                 else{
  69.                     strcpy(logtitle[i],
  70.                             title[intext->text[logindex].title.index]);
  71.                     logkind[i]=1;
  72.                 }
  73.             }
  74.             else{
  75.                 logtitle[i][0]=0x00;
  76.             }
  77.         }
  78.  
  79.         for (k=0;k<TITLE_LINE_NO;k++){
  80.             if (logkind[k]==0) tcol=TEXT_COL;
  81.             else tcol=NAME_COL;
  82.             linedspv ( 2, k*18+69, logtitle[k],0,tcol,BACK_COL);
  83.         }
  84.  
  85.         n_menu[0].xpos=0;
  86.         n_menu[0].ypos=35;
  87.         n_menu[0].xsize=640;
  88.         n_menu[0].ysize=414;
  89.         n_menu[0].xbtnsize=640;
  90.         n_menu[0].ybtnsize=18;
  91.         n_menu[0].ful=0;
  92.         n_menu[0].disp=0;
  93.         n_menu[0].ini_digit=0;
  94.         while ( (result = panelread (1, n_menu, 1)) >= 2000 );
  95.         if ( result<0 ) action=0;
  96.         else{
  97.             if ( result < 1000 ){
  98.                 action=1;
  99.                 pos=result;
  100.             }
  101.             else{
  102.                 action=2;
  103.                 pos=result-1000;
  104.             }
  105.         }
  106.  
  107.         switch ( action ){
  108.             case 0 :
  109.                 flag=0;
  110.                 MOS_disp( 0 );
  111.                 EGB_writePage(egbwork,1);
  112.                 box( 0,35,639,459,0,1 );
  113.                 EGB_writePage(egbwork,0);
  114.                 break;
  115.             case 1 :
  116.                 if ( pos==0 ){
  117.                     if (*textno+TITLE_LINE_NO < max_text)
  118.                             *textno=*textno+TITLE_LINE_NO;
  119.                 }
  120.                 else{
  121.                     *textno=*textno+pos-1;
  122.                     if ( *textno>max_text-1 ) *textno=max_text-1;
  123.                     if (intext->text[disptext[*textno]].title.id==TITLE_ID){
  124.                         for ( n=*textno;n<max_text-1;n++ ){
  125.                             if (intext->text[disptext[n]].text.id
  126.                                                     != TITLE_ID ) break;
  127.                         }
  128.                         *textno=n;
  129.                     }
  130.                     flag=0;
  131.                     MOS_disp( 0 );
  132.                     EGB_writePage(egbwork,1);
  133.                     box( 0,35,639,459,0,1 );
  134.                     EGB_writePage(egbwork,0);
  135.                 }
  136.                 break;
  137.             case 2 :
  138.                 if ( pos==0 ){
  139.                     *textno=*textno-TITLE_LINE_NO;
  140.                     if (*textno<0) *textno=0;
  141.                 }
  142.                 else{
  143.                     flag=0;
  144.                     MOS_disp( 0 );
  145.                     EGB_writePage(egbwork,1);
  146.                     box( 0,35,639,459,0,1 );
  147.                     EGB_writePage(egbwork,0);
  148.                     break;
  149.                 }
  150.                 break;
  151.         }
  152.         EGB_color(egbwork, 0, TEXT_COL);
  153.         EGB_clearScreen(egbwork);
  154.     }
  155.     MOS_disp( 0 );
  156.     EGB_color(egbwork, 0, TEXT_COL);
  157.     EGB_color(egbwork, 1, BACK_COL);
  158.  
  159.     return(0);
  160.  
  161. }
  162.  
  163. /*
  164.         display charactor set with comment level mark
  165. */
  166. void    lineset(char *src, char *dest, int com)
  167. {
  168.     int        i;
  169.  
  170.     if (dispmode==NORMAL_MODE){
  171.         com=0;
  172.     }
  173.     else{
  174.         switch (com){
  175.             case 0 :
  176.                 break;
  177.             case 1 :
  178.                 dest[0]=0x84;
  179.                 dest[1]=0xa4;
  180.                 break;
  181.             default :
  182.                 for (i=0;i<=com-2;i++) dest[i]=0x20;
  183.                 dest[com-1]=0x84;
  184.                 dest[com]=0xa4;
  185.                 break;
  186.         }
  187.     }
  188.     if(com==0){
  189.         for (i=0;i<80;i++){
  190.             if (src[i]==0x0d && src[i+1]==0x0a){
  191.                 dest[i]=0x00;
  192.                 break;
  193.             }
  194.             else{
  195.                 dest[i]=src[i];
  196.             }
  197.         }
  198.     }
  199.     else{
  200.         for (i=0;i<80-com;i++){
  201.             if (src[i]==0x0d && src[i+1]==0x0a){
  202.                 dest[i+com+1]=0x00;
  203.                 break;
  204.             }
  205.             else{
  206.                 dest[i+com+1]=src[i];
  207.             }
  208.         }
  209.     }
  210.     dest[81]=0x00;
  211.     return;
  212. }
  213.